#include "main.h"
#include "MassStorage.h"
#include "FlashDisk.h"
#include "app_usbmsc.h"
#include "aky_program/aky_com_include.h"

void app_usbmsc_handler(void)
{
    GPIO_Init(USBMSC_CTRL_PORT, USBMSC_CTRL_PIN, 0, 0, 1, 0); //????,?????U???
    for (uint32_t i = 0; i < CyclesPerUs * 1000; i++)
        __NOP();
    #if 00 && (AKY_DEBUG_ENABLE == 1)

    #else
     if(GPIO_GetBit(USBMSC_CTRL_PORT, USBMSC_CTRL_PIN) == 1)

    #endif
    {
        uint32_t n=0;
        SYS->USBPHYCR = 0x000001db;
        SYS->USBCR = 0;
        MSC_Init();
        USBD_Open(); 
        while(1==1)
        {
            MSC_ProcessOUT();
            
            if(++n % 1000000 == 0)
            {
                FlashDiskFlush();
            }
        }
    }
}